{% extends 'base.html' %}
{% block title %}购物车{% endblock %}
{% block content %}
    <style type="text/css">
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 20px;
        }
        .container {
            display: flex;
            justify-content: space-between;
        }
        .cart {
            flex: 2;
            margin-right: 20px;
            padding: 20px;
            border: 1px solid #ccc;
            border-radius: 5px;
        }
        .summary {
            flex: 1;
            padding: 20px;
            border: 1px solid #ccc;
            border-radius: 5px;
        }
        .cart-item {
            display: flex;
            justify-content: space-between;
            margin-bottom: 15px;
            padding: 10px;
            border-bottom: 1px solid #eee;
        }
        .cart-item img {
            width: 50px; /* Adjust the size as necessary */
            margin-right: 10px;
        }
        .btn {
            background-color: blue;
            color: white;
            padding: 10px 15px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }
        .total {
            font-size: 18px;
            margin-top: 20px;
        }
    </style>
    <div class="container">
        <div class="cart">
            <h1>购物车</h1>
            <p>全部商品 ({{ cart_books|length }})</p>
            {% for book in cart_books %}
                <div class="cart-item">
                    <div>
                        <p>书名: {{ book.bookname }}</p>
                        <p>价格: ¥{{ book.price }}</p>
                        <p>专业: {{ book.major }}</p>
                        <p>年级: {{ book.grade }}</p>
                        <p>QQ: {{ book.qq }}</p>
                    </div>
                    <div>
                        <form action="/delete1/{{ book.id }}" method="post" style="display:inline;">
                            {% csrf_token %}
                            <button type="submit" class="btn">删除</button>
                        </form>
                    </div>
                </div>
            {% endfor %}

        </div>
        <div class="summary">
            <h2>结算明细</h2>
            <p class="total">合计: ¥{{ total_price }}</p>
            <form action="{% url 'checkout' %}" method="post">
                {% csrf_token %}
                <button type="submit" class="btn">结算</button>
            </form>
        </div>
    </div>
{% endblock %}